import Vue from 'vue'
import Router from 'vue-router'

//首页3 tab 容器
const Main = resolve => {
  require.ensure(['@/components/common_main.vue'], () => {
    resolve(require('@/components/common_main.vue'))
  })
}
//预约
const Index = resolve => {
  require.ensure(['@/views/index.vue'], () => {
    resolve(require('@/views/index.vue'))
  })
}
//个人中心
const Personal = resolve => {
  require.ensure(['@/views/personal.vue'], () => {
    resolve(require('@/views/personal.vue'))
  })
}
//登录页
const Login = resolve => {
  require.ensure(['@/views/login.vue'], () => {
    resolve(require('@/views/login.vue'))
  })
}
// 球场列表
const Court = resolve => {
  require.ensure(['@/views/court.vue'], () => {
    resolve(require('@/views/court.vue'))
  })
}
// 球场详情
const CourtDetail = resolve => {
  require.ensure(['@/views/court_detail.vue'], () => {
    resolve(require('@/views/court_detail.vue'))
  })
}
// 课程详情
const CourseDetail = resolve => {
  require.ensure(['@/views/course_detail.vue'], () => {
    resolve(require('@/views/course_detail.vue'))
  })
}
// 教练详情
const CoachDetail = resolve => {
  require.ensure(['@/views/coach_detail.vue'], () => {
    resolve(require('@/views/coach_detail.vue'))
  })
}
//订单确认
const OrderConfirm = resolve => {
  require.ensure(['@/views/order_confirm.vue'], () => {
    resolve(require('@/views/order_confirm.vue'))
  })
}
//订单详情
const OrderDetail = resolve => {
  require.ensure(['@/views/order_detail.vue'], () => {
    resolve(require('@/views/order_detail.vue'))
  })
}
//教练-订单详情
const Coach_OrderDetail = resolve => {
  require.ensure(['@/views/coach-order_detail.vue'], () => {
    resolve(require('@/views/coach-order_detail.vue'))
  })
}
//财富
const Property = resolve => {
  require.ensure(['@/views/property.vue'], () => {
    resolve(require('@/views/property.vue'))
  })
}
// 财富页头部
const PropertyHeader = resolve => {
  require.ensure(['@/components/property/header'], () => {
    resolve(require('@/components/property/header'))
  })
}
// 兑换优惠券头部
const CouponHeader = resolve => {
  require.ensure(['@/components/property/coupon_header'], () => {
    resolve(require('@/components/property/coupon_header'))
  })
}
//充值
// const Charge = resolve => {
//   require.ensure(['@/views/charge.vue'], () => {
//     resolve(require('@/views/charge.vue'))
//   })
// }
//视频观看
const Video = resolve => {
  require.ensure(['@/views/video.vue'], () => {
    resolve(require('@/views/video.vue'))
  })
}
//视频推荐列表
const Videos = resolve => {
  require.ensure(['@/views/videos.vue'], () => {
    resolve(require('@/views/videos.vue'))
  })
}
//订单列表（无订单）
const NoOrder = resolve => {
  require.ensure(['@/views/no_order.vue'], () => {
    resolve(require('@/views/no_order.vue'))
  })
}
//订单列表
const Orders = resolve => {
  require.ensure(['@/views/orders.vue'], () => {
    resolve(require('@/views/orders.vue'))
  })
}
//订单列表
const Coach_Orders = resolve => {
  require.ensure(['@/views/coach-orders.vue'], () => {
    resolve(require('@/views/coach-orders.vue'))
  })
}
//订场页面
const bookCourt = resolve => {
  require.ensure(['@/views/book_court.vue'], () => {
    resolve(require('@/views/book_court.vue'))
  })
}

Vue.use(Router)

export default new Router({
  routes: [
    {
      path: '/',
      // name: 'main',
      component: Main,
      children: [
        {
          path: '',
          name: 'main-index',
          component: Index
        },
        {
          path: 'court',
          name: 'main-court',
          component: Court
        },
        {
          path: 'personal',
          name: 'main-personal',
          component: Personal,
          meta: { requiresAuth: true }
        },
      ]
    },
    {
      path: '/login',
      name: 'login',
      component: Login
    },
    {
      path: '/court/:court_id',
      name: 'court_detail',
      component: CourtDetail
    },
    {
      path: '/course/:course_id',
      name: 'course_detail',
      component: CourseDetail
    },
    {
      path: '/book/:book_id',
      name: 'book_court',
      component: bookCourt
    },
    {
      path: '/coach/:coach_id',
      name: 'coach_detail',
      component: CoachDetail
    },
    {
      path: '/property',
      // name: 'property',
      component: Property,
      meta: { requiresAuth: true },
      children: [
        {
          path: '',
          name: 'property-main',
          component: PropertyHeader
        },
        {
          path: 'coupon',
          name: 'property-coupon',
          component: CouponHeader
        }
      ]
    },
    // {
    //   path: '/charge',
    //   name: 'charge',
    //   component: Charge
    // },
    {
      path: '/video/:video_id',
      name: 'video',
      component: Video,
      meta: { requiresAuth: true, checkLocator: true }
    },
    {
      path: '/video',//TODO: 临时修改
      // path: '/videos',
      name: 'videos',
      component: Videos,
      meta: { requiresAuth: true}
    },
    {
      path: '/noorder',
      name: 'no_order',
      component: NoOrder,
      meta: { requiresAuth: true },
    },
    {
      path: '/orders',
      name: 'orders',
      component: Orders,
      meta: { requiresAuth: true },
    },
    {
      path: '/order/:order_id',
      name: 'order',
      component: OrderDetail,
      meta: { requiresAuth: true },
    },
    {
      path: '/coach-orders/:coach_id',
      bane: 'coach-orders',
      component: Coach_Orders,
      meta: { requiresAuth: true },
    },
    {
      path: '/coach-order/:subject_id',
      name: 'coach-order',
      component: Coach_OrderDetail,
      meta: { requiresAuth: true },
    },
    {
      path: '/confirm/:subject_id',
      name: 'confirm',
      component: OrderConfirm,
      meta: { requiresAuth: true, checkLocator: true },
    },
  ]
})
